<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>13验证Diffing算法</title>
</head>
<body>
    <div id="test">

    </div>
    <!-- 引入react核心库 -->
    <script crossorigin src="../17.0.1/react.development.js"></script>
    <!-- 引入react-dom，用于支持react操作DOM -->
    <script crossorigin src="../17.0.1/react-dom.development.js"></script>
    <!-- 引入babel，用于将jsx转为js -->
    <script type="text/javascript" src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
    <script type="text/javascript" src="https://unpkg.com/prop-types@15.6.2/prop-types.js"></script> 
    <script type="text/babel">
        class Timer extends React.Component{
            state = {date:new Date()}
            
            componentDidMount(){
                console.log('--componentDidMount--')
                setInterval(()=>{
                    this.setState({
                        date:new Date()
                    })
                },1000)
            }

            render(){
                console.log('--render--')
                return(
                    <div>
                        <h1>Hello </h1>
                        <input type="text"/>
                        <span>
                            现在是:{this.state.date.toTimeString()}
                            <input type="text"/>
                        </span>
                    </div>
                )
            }
        }
        ReactDOM.render(<Timer/>,document.getElementById('test'))
    </script>
</body>
</html>